package WebDriverPackage;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

import java.io.File;

/**
 * Created with IntelliJ IDEA.
 * User: C13T
 * Date: 10.07.13
 * Time: 19:21
 * To change this template use File | Settings | File Templates.
 */
public class WebDriverFactory {
    private static WebDriver driver;

    public static WebDriver createDriver(String browserName){
        if (browserName.equals("firefox")){
            driver = new FirefoxDriver();
        }
        else if (browserName.equals("chrome")){

            File file = new File("F:\\Drivers\\chromedriver.exe"); //C:\Program Files (x86)\Google\Chrome\Application
            System.setProperty("webdriver.chrome.driver",file.getAbsolutePath());// "c:\\WebDrivers\\chromedriver.exe");//file.getAbsolutePath());
            driver = new ChromeDriver();
        }
        else if (browserName.equals("ie")){
            File file = new File("F:\\Drivers\\IEDriverServer.exe");
            System.setProperty("webdriver.ie.driver",file.getAbsolutePath());
            driver = new InternetExplorerDriver();
        }
        return driver;
    }
}

